package org.bet.web.vaadin;

import javax.annotation.PostConstruct;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;

@Component
public class MainWindow extends Window {
	private static final long serialVersionUID = -9009579211737217667L;
	
	private final Log logger = LogFactory.getLog(getClass());
    private static int instanceId = 0;

    @Autowired
    private TextLabelService textLabelService;

    public MainWindow() {
        super(BioEnTreeApplication.TITLE);

        VerticalLayout layout = (VerticalLayout) getContent();
        layout.addComponent(new Label(BioEnTreeApplication.TITLE));

        instanceId++;
    }

    @PostConstruct
    public void addInstanceLabels() {
    	logger.debug(">>>>>>Add InstanceLabels.....");

    	VerticalLayout layout = (VerticalLayout) getContent();
        layout.addComponent(new Label("MainWindow instanceId: " + instanceId));
        layout.addComponent(new Label(textLabelService.getInstanceText()));
    }
}